﻿Imports System.Web
Imports System.Web.Services
Imports System.IO

Public Class Handler
    Implements System.Web.IHttpHandler

    Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

        Dim imgUpload As HttpPostedFile = context.Request.Files("Filedata")

        Dim folder As String = context.Request("folder").ToString()
        Dim savepath As String = ""
        Dim tempPath As String = ""
        tempPath = folder

        savepath = context.Server.MapPath(tempPath)
        Dim filename As String = imgUpload.FileName
        If Not Directory.Exists(savepath) Then
            Directory.CreateDirectory(savepath)
        End If

        imgUpload.SaveAs((savepath & "\") + filename)
        context.Response.Write((tempPath & "/") + filename)
        context.Response.StatusCode = 200

    End Sub

    ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property

End Class